package com.thiswhyme.stream.rabbit.producer.service;

import com.thiswhyme.stream.rabbit.publish.AbstractCommonPublisher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.stereotype.Service;

import com.thiswhyme.stream.rabbit.producer.channel.OutputChannel;

/**
 * @description:
 * @author: thiswhyme
 * @date: 2021/1/27
 */
@Service
public class DemoPublisher extends AbstractCommonPublisher {

    @Autowired
    private OutputChannel outputChannel;

    @Override
    public MessageChannel getOutputChannel() {
        return outputChannel.confirmOutputChannel();
    }

    @ServiceActivator(inputChannel = "confirmAckSuccessChannel")
    @Override
    public void confirmSuccess(Message<?> message) {
        System.out.println("===============DemoPublisher 消息已投递到exchange:  " + message);
    }

    @ServiceActivator(inputChannel = "destination.confirm-ack.errors")
    @Override
    public void confirmFail(Message<?> message) {
        System.out.println("===============DemoPublisher 消息未路由到队列" + message);
    }
}
